package com.hc.sss.service.impl;

import java.util.List;
import java.util.Map;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.hc.sss.common.ResultMap;
import com.hc.sss.pojo.LineUp;
import com.hc.sss.pojo.Take;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.hc.sss.mapper.LineUpMapper;
import com.hc.sss.service.LineUpService;

@Service
public class LineUpServiceImpl implements LineUpService {

	@Autowired
	private LineUpMapper lineUpMapper;
	
	@Override
	public int insertLineUp(Map lineUpMap) {
		// TODO Auto-generated method stub
		return lineUpMapper.insertLineUp(lineUpMap);
	}

	@Override
	public ResultMap<LineUp> findListLineUpByPublish(Map<String, Object> param) {
		ResultMap<LineUp> resultMap = new ResultMap<LineUp>();
		Integer page = 1;
		Integer limit = 5;
		if (param.get("page") != null && !"".equals(param.get("page"))) {
			page = Integer.valueOf(param.get("page").toString());
		}
		if (param.get("limit") != null && !"".equals(param.get("limit"))) {
			limit = Integer.valueOf(param.get("limit").toString());
		}
		PageHelper.startPage(page, limit);
		List<LineUp> list = lineUpMapper.findListLineUpByPublish(param);
		PageInfo<LineUp> info = new PageInfo<>(list);
		resultMap.setData(list);
		resultMap.setCount((int)info.getTotal());
		return resultMap;
	}

}
